package ksu_product.proGen.service;

import java.util.List;

import ksu_product.proGen.dto.TableDTO;
import ksu_product.proGen.util.SystemConfig;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Generator {

	private static ApplicationContext context;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		context = new ClassPathXmlApplicationContext("applicationContext.xml");
		GeneratorService genService = (GeneratorService) context.getBean("generatorService");
		List<TableDTO> tableList = SystemConfig.getTableList();
		if (tableList != null && tableList.size() > 0) {
			for (TableDTO tableDTO : tableList) {
				String selectSql = genService.getSelectSql(tableDTO.getTableName());
				tableDTO.setSelectSql(selectSql);
				tableDTO.setTableName(tableDTO.getTableName());
				List<TableDTO> tableColumnList = genService.getTableInfo(tableDTO);
				genService.createClass(tableColumnList, tableDTO);
			}
		}

	}

}
